# $Id$
# Maintainer: Jan de Groot <jgc@archlinux.org>

# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
#  - enable omap, exynos, freedreno for v7
#  - drop valgrind makdepend for v5 and v6
#  - upstream fix to valgrind detection

pkgname=libdrm
pkgver=2.4.64
pkgrel=1
pkgdesc="Userspace interface to kernel DRM services"
arch=(i686 x86_64)
license=('custom')
depends=('glibc' 'libpciaccess')
makedepends=('xorg-util-macros')
makedepends_armv7h=('valgrind')
checkdepends=('cairo')
replaces=('libdrm-new' 'libdrm-nouveau')
url="http://dri.freedesktop.org/"
source=(http://dri.freedesktop.org/$pkgname/$pkgname-$pkgver.tar.bz2{,.sig}
        COPYING)
sha256sums=('b60786fe7d6e42adb3966ce1a658f63fec528d537396381cbda93bcc99a934b6'
            'SKIP'
            '9631d4f694952e3e6ae5a05534c2e93e994e47d3413677a3a00e45c8cef6db93')
validpgpkeys=('B97BD6A80CAC4981091AE547FE558C72A67013C3') # Maarten Lankhorst <maarten.lankhorst@canonical.com>
validpgpkeys+=('215DEE688925CCB965BE5DA97C03D7797B6E1AE2') # Damien Lespiau <damien.lespiau@intel.com>
validpgpkeys+=('10A6D91DA1B05BD29F6DEBAC0C74F35979C486BE') # David Airlie <airlied@redhat.com>
validpgpkeys+=('8703B6700E7EE06D7A39B8D6EDAE37B02CEB490D') # Emil Velikov <emil.l.velikov@gmail.com>
validpgpkeys+=('D6285B5E899299F3DA746184191C9B905522B045') # Rob Clark <robclark@freedesktop.org>

prepare() {
  cd $pkgname-$pkgver

  # pthread is useless in Linux
  sed -i "/pthread-stubs/d" configure.ac
  autoreconf --force --install

}

build() {
  cd $pkgname-$pkgver  
  [[ "$CARCH" == "armv7h" ]] && CONFIG="--enable-omap-experimental-api --enable-exynos-experimental-api --enable-tegra-experimental-api"
  ./configure --prefix=/usr --enable-udev $CONFIG
  make
}

check() {
  cd $pkgname-$pkgver
  make -k check
}

package() {
  cd $pkgname-$pkgver
  make DESTDIR="$pkgdir" install
  install -m755 -d "$pkgdir/usr/share/licenses/$pkgname"
  install -m644 ../COPYING "$pkgdir/usr/share/licenses/$pkgname/"
}
